from elasticsearch import Elasticsearch

HOSTS = 'localhost'
INDEX = 'sina-post'  # 索引（类似MySQL库名）

es = Elasticsearch(HOSTS)
es.index(index=INDEX, doc_type="test-type", id=42, body={"any": "data"})